package com.workoutdiary.ui;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.swing.trial.MainAreaFrame;
import com.workoutdiary.controller.MainController;
import com.workoutdiary.dao.MCycleRecordDao;
import com.workoutdiary.data.DbManager;
import com.workoutdiary.data.Table;
import com.workoutdiary.entities.MCycleRecord;
import com.workoutdiary.entities.User;

public class Program {
	
	public static void executeQuery(String sql) {
		
		DbManager manager = new DbManager();
		Connection conn = manager.createConnection();
		PreparedStatement pst = manager.createPreparedStatement(sql, conn);
		
		try {
			boolean res = pst.execute();
			System.out.println(res);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		manager.close(conn);
	}
	
	public static void main(String [] args) {
//		System.out.println("Workout diary");
//		
//		User user = new User("Oksana", "Vyshyns'ka", "erka_218@mail.ru", "1");
//		UserDao userDao = new UserDao();
//		User user = userDao.read("michael.tys8@gmail.com", "1");
//		System.out.println(user);
//		userDao.create(user);
		
//		List<User> users = userDao.getAll();
		
//		for (int i = 0; i < users.size(); i++) {
//			System.out.println(users.get(i));
//		}
//		
//		
//		MCycleRecordDao mCycleRecordDao = new MCycleRecordDao();
//		
//		List<MCycleRecord> records = mCycleRecordDao.getAll();
//		
//		for(MCycleRecord r: records)
//			System.out.println(r);
//		
		MainController controller = MainController.getController();
		
		if(controller == null)
			System.out.println("null");
		
		MainAreaFrame mainFrame = new MainAreaFrame();
		mainFrame.setFormListener(controller);
		mainFrame.show();
		
//		MCycleRecordDao mCycleRecordDao = new MCycleRecordDao();
//		MCycleRecord record = new MCycleRecord(2, System.currentTimeMillis(), 1, "description");
//		mCycleRecordDao.create(record);
		
	}

}

